package com.zjx.processor.bean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;


/**
 * Bean组件的 PostProcessor；
 */
@Component
public class MyBeanPostProcessor implements BeanPostProcessor , InitializingBean {
	public MyBeanPostProcessor(){
		System.out.println("MyBeanPostProcessor...");
	}
	public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
		System.out.println("MyBeanPostProcessor...postProcessAfterInitialization..."+bean+"==>"+beanName);
		return bean;
	}
	public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
		System.out.println("MyBeanPostProcessor...postProcessBeforeInitialization..."+bean+"==>"+beanName);
		return bean; // new Object();
	}


	@Override
	public void afterPropertiesSet() throws Exception {
		//这里发生在给bean对象所有属性赋值后，如果我们再做处理
		//比如我们从nacos config中拿到所有的链接数据库数据源的配置，属性变量都付完值后
		//进行初始化数据源
		//url password admin

	}
}
